package com.xywy.common.util;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.xywy.R;

/**
 * Created by xiaogd on 7/14/14.
 */
public class DialogUtils {

    /**
     * 确定取消信息框 *
     */
    public static final int DIALOG_0 = 1;
    /**
     * 多个按钮信息框 *
     */
    public static final int DIALOG_1 = 2;
    /**
     * menu 列表框 *
     */
    public static final int DIALOG_2 = 3;
    /**
     * 进度条框 *
     */
    public static final int DIALOG_3 = 4;
    /**
     * 单项选择列表框 *
     */
    public static final int DIALOG_4 = 5;

    /**
     * 问医生 menu 列表框
     */
    public static final int DIALOG_5 = 6;


    public static AlertDialog creatDialog(Context context, int id, Bundle bundle,
                                          View.OnClickListener onClickListener) {

        final AlertDialog dialog = new AlertDialog.Builder(context).create();
        dialog.show();
        Window window = dialog.getWindow();
        switch (id) {
            case DIALOG_0:  // 确定取消信息框
                window.setContentView(R.layout.dialog_confirm_cancel);
                TextView tvtitle = (TextView) window.findViewById(R.id.tv_dialog_title);
                Button cancel = (Button) window.findViewById(R.id.dialog_button_cancel);
                Button ok = (Button) window.findViewById(R.id.dialog_button_ok);

                tvtitle.setText(bundle.getString("title"));
                cancel.setOnClickListener(onClickListener);
                ok.setOnClickListener(onClickListener);
                break;

            case DIALOG_2:  // menu 列表框
                window.setContentView(R.layout.dialog_menu);
                TextView tvtitle2 = (TextView) window.findViewById(R.id.tv_dialog_menu_title);
                TextView delete = (TextView) window.findViewById(R.id.tv_dialog_menu_item);

                tvtitle2.setText(bundle.getString("title"));
                delete.setText(bundle.getString("delete"));
                delete.setOnClickListener(onClickListener);
                break;
            case DIALOG_5:  //问医生  menu 列表框
                window.setContentView(R.layout.dialog_menu_yys);
                TextView yysCollect = (TextView) window.findViewById(R.id.tv_dialog_yys_collect);
                TextView yysDelte = (TextView) window.findViewById(R.id.tv_dialog_yys_delete);

                yysCollect.setOnClickListener(onClickListener);
                yysDelte.setOnClickListener(onClickListener);
                break;
        }
        return dialog;
    }

}
